home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 138
/
Volume 138 Aug 19 2011 - Damaged.iso
/
Games
/
the_independent.swf
/
scripts
/
frame_5
/
DoAction_3.as
< prev
next >
Wrap
Text File
|
2011-08-19
|
7KB
|
272 lines
function populate()
{
var p = _root.attachMovie("paperBoy","paperBoy",4500);
p._y = 760;
p._x = 150;
p.onenterframe = movePeople;
var p = _root.attachMovie("van","van",4501);
p._y = 760;
p._x = 0;
p.onenterframe = movePeople;
var i = 0;
while(i <= 5)
{
var p = _root.attachMovie("pigeon","pigeon" + i,4900 + i);
p._x = p.relX = math.random() * 1500;
p._y = p.relY = 350 - i * 50;
p.xAcc = math.random() * 3 + 3;
p.yAcc = 0;
p._xscale = -100;
p.num = i;
p["class"] = "pigeon";
p.onenterframe = float;
i++;
}
aGroundPos = new array();
cityLength = 2000;
cityPos = 0;
oPeople.num = 10;
oBackBuild.num = 2;
oForeBuild.num = 2;
oObstacles.num = 10;
oPeople.para = 1;
oBackBuild.para = 0.5;
oForeBuild.para = 0.75;
oObstacles.para = 1;
oPeople.aPos = [];
oBackBuild.aPos = [];
oForeBuild.aPos = [];
oObstacles.aPos = [];
oPeople.aType = [];
oObstacles.aType = [];
oForeBuild.aType = [];
oBackBuild.aType = [];
createPosArray(oPeople);
createPosArray(oObstacles);
createPosArray(oForeBuild);
createPosArray(oBackBuild);
var f = _root.attachMovie("duffer","duffer",5500);
f._x = checkPos();
f._y = _global.movieHeight + 360;
f["class"] = oBaddy;
f.onenterframe = movePeople;
var f = _root.attachMovie("scum","scum",5501);
f._x = checkPos();
f._y = _global.movieHeight + 360;
f["class"] = oBaddy;
f.onenterframe = movePeople;
var f = _root.attachMovie("blankMC","floater",100000);
f._x = f.relX = 0;
f._y = f.relY = 500;
f.xAcc = 5;
f.yAcc = 0;
f.onenterframe = float;
var c = _root.attachMovie("blankMC","controller",100001);
c._x = 250;
c.targ = floater;
c.onenterframe = control;
delete c;
}
function checkPos()
{
var curX = math.round(math.random() * (cityLength - 400) + 300);
aGroundPos.push(curX);
var breaker = 0;
var k = 0;
while(k <= aGroundPos.length - 2)
{
if(curX > aGroundPos[k] - 40 && curX < aGroundPos[k] + 40)
{
curX = math.round(math.random() * (cityLength - 800) + 400);
aGroundPos[aGroundPos.length - 1] = curX;
k = -1;
breaker++;
}
if(breaker > 100)
{
trace("broken");
break;
}
k++;
}
return curX;
}
function removeBuildings(targ)
{
var i = 0;
while(i <= _root["o" + targ].aPos.length - 2)
{
_root[targ + i].removeMovieClip();
i++;
}
}
function createPosArray(oName)
{
if(oName.num != 10)
{
var i = 0;
while(i < math.round((cityLength + 1000) * oName.para / (_global.movieWidth / oName.num)))
{
oName.aPos.push(math.round(math.random() * _global.movieWidth / oName.num + i * (_global.movieWidth / oName.num)));
oName.aType.push(math.ceil(math.random() * oName.typeNum));
trace(oName.aPos.length);
i++;
}
oName.aPos.push(undefined);
var j = 0;
while(oName.aPos[j] < _global.movieWidth + 150)
{
var s = _root.attachMovie(oName.title,oName.title + j,oName.lev + j);
s._y = oName.yDepth + _global.movieHeight;
s._x = oName.aPos[j];
s.gotoandstop(oName.aType[j]);
s.num = j;
j++;
s.Class = oName;
s.Class.curY = s._y;
s.onenterframe = move;
}
oName.nextBuild = j;
oName.prevBuild = -1;
}
else
{
var i = 0;
while(i <= 9)
{
oName.aPos.push(math.round(math.random() * (cityLength - 400) + 300));
aGroundPos.push(oName.aPos[i]);
if(aGroundPos.length > 1)
{
var breaker = 0;
var k = 0;
while(k <= aGroundPos.length - 2)
{
if(oName.aPos[i] > aGroundPos[k] - 40 && oName.aPos[i] < aGroundPos[k] + 40)
{
oName.aPos[i] = math.round(math.random() * (cityLength - 800) + 400);
aGroundPos[aGroundPos.length - 1] = oName.aPos[i];
k = -1;
breaker++;
}
if(breaker > 100)
{
trace("broken");
break;
}
k++;
}
}
oName.aType.push(math.ceil(math.random() * oName.typeNum));
i++;
}
var j = 0;
while(j <= 9)
{
var s = _root.attachMovie(oName.title,oName.title + j,oName.lev + j);
s._y = oName.yDepth + _global.movieHeight;
s._x = oName.aPos[j];
s.gotoandstop(oName.aType[j]);
s.num = j;
s.Class = oName;
s.onenterframe = movepeople;
j++;
}
}
}
function slideInPrep(targ, pos)
{
if(pos == "centre")
{
targ._y = math.round((_global.movieHeight - targ._height) / 2);
}
else if(pos == "top")
{
targ._y = 0;
}
targ.endX = math.round((_global.movieWidth - targ._width) / 2);
trace(targ._width);
targ.easeIn = 10;
targ.easeMulti = 4;
targ.acc = targ.easeIn * targ.easeMulti;
var i = targ.easeIn;
while(i >= 1)
{
targ.endX += i;
i--;
}
targ._x = math.round((_global.movieWidth - targ.endX) / targ.acc) * targ.acc + targ.endX;
targ.onenterframe = slideIn;
}
function slideIn()
{
this._x -= this.acc;
if(this._x == this.endX)
{
this.acc = this.easeIn;
}
else if(this._x < this.endX)
{
this.acc--;
}
if(this.acc == 0)
{
delete this.onenterframe;
}
}
function slideOutPrep(targ)
{
targ.acc = 0;
targ.onenterframe = slideOut;
}
function slideOut()
{
this._x -= this.acc;
this.acc += 10;
if(this._x < - this._width)
{
this.removeMovieClip();
}
}
function soundPrep()
{
createEmptyMovieClip("musicControl",750);
createEmptyMovieClip("fxControl",751);
curSound = new Sound(fxControl);
bgSound = new Sound(musicControl);
bgSound.attachSound("indyMusic");
bgSound.setVolume(85);
var b = _root.attachMovie("soundButton","soundButton",19001);
b._x = 5;
b._y = 365;
b.soundIcon.stop();
_global.soundOn = true;
}
function playFX(cur)
{
if(_global.sound)
{
curSound.attachSound(cur);
curSound.start();
}
}
function soundState(n)
{
if(n == 2)
{
if(_global.section == 1)
{
bgSound.setVolume(0);
}
_global.sound = false;
}
else
{
if(_global.section == 1)
{
bgSound.setVolume(85);
}
_global.sound = true;
}
}